function getChildren() {
	var menu1 = $('select[name="menu1"]').find('option:selected');
	if (menu1.val() == -1) {
		return;
	}

	$
			.ajax({
				url : "menu/getChildren",
				type : "POST",
				// data:"name="+name.val()+"&sex="+sex.val()+"&home="+home.val(),
				data : {
					parrentId : menu1.val()
				},
				dataType : 'json',
				success : function(result) {
					length = result.length;
					if (length != 0) {
						str = "<select name='menu2' id='menu2'><option value='-1'>--请选择--</option>"
						for ( var i = 0; i < length; i++) {
							str += "<option value=" + result[i].menuId + ">"
									+ result[i].name + "</option>";
						}
						str += "</select>";
						$('#childrenMenus').html(str);
					} else {
						$('#childrenMenus').html("");
					}
				}
			});
}

function add() {
	var title = $("#title");
	if (null == title.val() || "" == title.val()) {
		alert("请输入标题！");
		title.focus();
		return;
	}
	var content = CKEDITOR.instances.content.getData();
	if (content == null || content == "") {
		CKEDITOR.instances.content.focus();
		alert("请填写内容！");
		return false;
	}
	var menu1 = $('select[name="menu1"]').find('option:selected');
	if (menu1.val() == -1) {
		alert("请选择菜单！");
		$("#menu1").focus();
		return;
	}
	var menuId = menu1.val();
	if ($("#menu2") == null) {
		var menu2 = $('select[name="menu2"]').find('option:selected');
		if (menu2.val() == -1) {
			alert("请选择菜单！");
			$("#menu2").focus();
			return;
		}
		menuId = menu2.val();
	}

	$.ajax({
		url : "article/add",
		type : "POST",
		data : {
			title : title.val(),
			publishTime : '2013-5-1',
			publisher : 'hisky',
			image : 'test.jpg',
			menuId : menuId,
			content : content

		},
		dataType : 'text',
		success : function(result) {
			if (result != 0) {
				alert("添加成功");
				window.opener.location.reload();
				window.close();
			} else {
				alert("添加失败");
			}
		}
	});
}
